package com.model;

// Generated 2013-8-25 14:56:38 by Hibernate Tools 3.6.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Question generated by hbm2java
 */
@Entity
@Table(name = "question")
public class Question implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5700446149653555039L;
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Integer id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "question_user_id", nullable = false)
	private User userByQuestionUserId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	private User userByUserId;

	@Column(name = "question", nullable = false, length = 65535)
	private String question;

	@Column(name = "answer", length = 65535)
	private String answer;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "question_at", nullable = false, length = 19)
	private Date questionAt;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "answer_at", length = 19)
	private Date answerAt;

	@Column(name = "agree_num", nullable = false)
	private int agreeNum;

	@Column(name = "disagree_num", nullable = false)
	private int disagreeNum;

	@Column(name = "favor_num", nullable = false)
	private int favorNum;

	@Column(name = "comments_num", nullable = false)
	private int commentsNum;
	
	@Column(name = "collect_num", nullable = false)
	private int collectNum;

	@Column(name = "user_score", nullable = false)
	private int userScore;

	@Column(name = "is_answered", nullable = false)
	private int isAnswered;

	@Column(name = "is_elite", nullable = false)
	private int isElite;

	@Column(name = "is_anonymous", nullable = false)
	private int isAnonymous;

	@Column(name = "is_public", nullable = false)
	private int isPublic;

	@Column(name = "is_ignore", nullable = false)
	private int isIgnore;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "question")
	private Set<QuestionAction> questionActions = new HashSet<QuestionAction>(0);

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "question")
	private Set<QuestionComment> questionComments = new HashSet<QuestionComment>(0);

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "question_tag", catalog = "askme", joinColumns = { @JoinColumn(name = "question_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "tag_id", nullable = false, updatable = false) })
	private Set<Tag> tags = new HashSet<Tag>(0);

	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "alliance_id", nullable = false)
	private Alliance alliance;
	
	@Column(name = "title_image",  length = 255)
	private String titleImage;
	
	@Column(name = "description",  length = 1024)
	private String description;
	
	public Question() {
	}

	public Question(User userByQuestionUserId, User userByUserId, String question, Date questionAt,
			int agreeNum, int disagreeNum, int favorNum, int userScore, byte isAnswered,
			byte isElite, byte isIgnore) {
		this.userByQuestionUserId = userByQuestionUserId;
		this.userByUserId = userByUserId;
		this.question = question;
		this.questionAt = questionAt;
		this.agreeNum = agreeNum;
		this.disagreeNum = disagreeNum;
		this.favorNum = favorNum;
		this.userScore = userScore;
		this.isAnswered = isAnswered;
		this.isElite = isElite;
		this.isIgnore = isIgnore;
	}

	public Question(User userByQuestionUserId, User userByUserId, String question, String answer,
			Date questionAt, Date answerAt, int agreeNum, int disagreeNum, int favorNum,
			int userScore, byte isAnswered, byte isElite, byte isIgnore,
			Set<QuestionAction> questionActions, Set<QuestionComment> questionComments,
			Set<Tag> tags) {
		this.userByQuestionUserId = userByQuestionUserId;
		this.userByUserId = userByUserId;
		this.question = question;
		this.answer = answer;
		this.questionAt = questionAt;
		this.answerAt = answerAt;
		this.agreeNum = agreeNum;
		this.disagreeNum = disagreeNum;
		this.favorNum = favorNum;
		this.userScore = userScore;
		this.isAnswered = isAnswered;
		this.isElite = isElite;
		this.isIgnore = isIgnore;
		this.questionActions = questionActions;
		this.questionComments = questionComments;
		this.tags = tags;
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public User getUserByQuestionUserId() {
		return this.userByQuestionUserId;
	}

	public void setUserByQuestionUserId(User userByQuestionUserId) {
		this.userByQuestionUserId = userByQuestionUserId;
	}

	public User getUserByUserId() {
		return this.userByUserId;
	}

	public void setUserByUserId(User userByUserId) {
		this.userByUserId = userByUserId;
	}

	public String getQuestion() {
		return this.question;
	}

	public void setQuestion(String question) {
		this.question = question;
	}

	public String getAnswer() {
		return this.answer;
	}

	public void setAnswer(String answer) {
		this.answer = answer;
	}

	public Date getQuestionAt() {
		return this.questionAt;
	}

	public void setQuestionAt(Date questionAt) {
		this.questionAt = questionAt;
	}

	public Date getAnswerAt() {
		return this.answerAt;
	}

	public void setAnswerAt(Date answerAt) {
		this.answerAt = answerAt;
	}

	public int getAgreeNum() {
		return this.agreeNum;
	}

	public void setAgreeNum(int agreeNum) {
		this.agreeNum = agreeNum;
	}

	public int getDisagreeNum() {
		return this.disagreeNum;
	}

	public void setDisagreeNum(int disagreeNum) {
		this.disagreeNum = disagreeNum;
	}

	public int getFavorNum() {
		return this.favorNum;
	}

	public void setFavorNum(int favorNum) {
		this.favorNum = favorNum;
	}

	public int getUserScore() {
		return this.userScore;
	}

	public void setUserScore(int userScore) {
		this.userScore = userScore;
	}

	public int getIsAnswered() {
		return isAnswered;
	}

	public void setIsAnswered(int isAnswered) {
		this.isAnswered = isAnswered;
	}

	public int getIsElite() {
		return isElite;
	}

	public void setIsElite(int isElite) {
		this.isElite = isElite;
	}

	public int getIsIgnore() {
		return isIgnore;
	}

	public void setIsIgnore(int isIgnore) {
		this.isIgnore = isIgnore;
	}

	public Set<QuestionAction> getQuestionActions() {
		return this.questionActions;
	}

	public void setQuestionActions(Set<QuestionAction> questionActions) {
		this.questionActions = questionActions;
	}

	public Set<QuestionComment> getQuestionComments() {
		return this.questionComments;
	}

	public void setQuestionComments(Set<QuestionComment> questionComments) {
		this.questionComments = questionComments;
	}

	public Set<Tag> getTags() {
		return this.tags;
	}

	public void setTags(Set<Tag> tags) {
		this.tags = tags;
	}

	public int getIsAnonymous() {
		return isAnonymous;
	}

	public void setIsAnonymous(int isAnonymous) {
		this.isAnonymous = isAnonymous;
	}

	public int getIsPublic() {
		return isPublic;
	}

	public void setIsPublic(int isPublic) {
		this.isPublic = isPublic;
	}

	public int getCommentsNum() {
		return commentsNum;
	}

	public void setCommentsNum(int commentsNum) {
		this.commentsNum = commentsNum;
	}

	public int getCollectNum() {
		return collectNum;
	}

	public void setCollectNum(int collectNum) {
		this.collectNum = collectNum;
	}

	public Alliance getAlliance() {
		return alliance;
	}

	public void setAlliance(Alliance alliance) {
		this.alliance = alliance;
	}

	public String getTitleImage() {
		return titleImage;
	}

	public void setTitleImage(String titleImage) {
		this.titleImage = titleImage;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


}
